from http import HTTPStatus
from dashscope import Generation
import dashscope
from dashscope.api_entities.dashscope_response import Role
dashscope.api_key = ''

def conversation_with_messages():
    messages = [{'role': Role.SYSTEM, 'content': """

                 """},
                {'role': Role.USER, 'content': """
      
                 """}]
    response = Generation.call(
        Generation.Models.qwen_max,
        messages=messages,
        result_format='message',  # set the result to be "message" format.
    )
    if response.status_code == HTTPStatus.OK:
        print(response.output.choices[0]['message']['content'])
        # append result to messages.
        messages.append({'role': response.output.choices[0]['message']['role'],
                         'content': response.output.choices[0]['message']['content']})

    messages.append({'role': Role.USER, 'content': """

                   """})
    # make second round call
    response = Generation.call(
        Generation.Models.qwen_max,
        messages=messages,
        result_format='message',  # set the result to be "message" format.
    )
    if response.status_code == HTTPStatus.OK:
        print(response.output.choices[0]['message']['content'])



if __name__ == '__main__':
    conversation_with_messages()
